Function.RegisterNamespace("Test.System.Script.ScriptLoader.Attributes");

[Fixture]
Test.System.Script.ScriptLoader.Attributes.ImportAttribute=function(){
    [Fixture]
    function ImportAttribute(){
        [Fact]
        function ThrowsIfPathIsOmitted(){
            var expected="System.Script.ScriptLoader.Attributes.ImportAttribute: 'path' must be convertible to String.";
            
            var actual=Record.Exception(function(){
                new System.Script.ScriptLoader.Attributes.ImportAttribute();
            });
            
            Assert.Equal(expected,actual);
        }
        
        [Fact]
        function ThrowsIfPathIsUndefined(){
            var expected="System.Script.ScriptLoader.Attributes.ImportAttribute: 'path' must be convertible to String.";
            
            var actual=Record.Exception(function(){
                new System.Script.ScriptLoader.Attributes.ImportAttribute(undefined);
            });
            
            Assert.Equal(expected,actual);
        }
        
        [Fact]
        function ThrowsIfPathIsNull(){
            var expected="System.Script.ScriptLoader.Attributes.ImportAttribute: 'path' must be convertible to String.";
            
            var actual=Record.Exception(function(){
                new System.Script.ScriptLoader.Attributes.ImportAttribute(null);
            });
            
            Assert.Equal(expected,actual);
        }
        
        [Fact]
        function ThrowsIfPathIsNotConvertibleToString(){
            var expected="System.Script.ScriptLoader.Attributes.ImportAttribute: 'path' must be convertible to String.";
            
            var actual=Record.Exception(function(){
                new System.Script.ScriptLoader.Attributes.ImportAttribute({toString:null});
            });
            
            Assert.Equal(expected,actual);
        }
        
        [Fact]
        function CallsScriptLoaderImport(){
            var targetImport=System.Script.ScriptLoader.Import;
            System.Script.ScriptLoader.Import=function(){
                actual=true;
            };
            var actual=false;
            
            new System.Script.ScriptLoader.Attributes.ImportAttribute('');
            System.Script.ScriptLoader.Import=targetImport;
            
            Assert.True(actual);
        }

        [Fact]
        function PassesPathToScriptLoaderImport(){
            var targetImport=System.Script.ScriptLoader.Import;
            System.Script.ScriptLoader.Import=function(path){
                actual=path;
            };
            var expected="expected";
            var actual=false;
            
            new System.Script.ScriptLoader.Attributes.ImportAttribute(expected);
            System.Script.ScriptLoader.Import=targetImport;
            
            Assert.Equal(expected,actual);
        }
    }
}
